﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.Collections.Generic;

namespace Artech.PetShop.Orders.BusinessEntity
{
    [DataContract(Namespace = "http://www.artech.com/petshop/")]
    public class Order
    {
        public Order()
        {
            this.Details = new List<OrderDetail>();
        }

        [DataMember]
        public Guid OrderNo
        { get; set; }

        [DataMember]
        public DateTime OrderDate
        { get; set; }

        [DataMember]
        public string OrderBy
        { get; set; }

        [DataMember]
        public IList<OrderDetail> Details
        { get; set; }

        public decimal TotalPrice
        {
            get
            {
                return (decimal)this.Details.Sum(detail => detail.Quantity * detail.UnitPrice);
            }
        }
    }
}
